<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Real Property and Business Permit</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="styles.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="nivo-slider.css" type="text/css" media="screen" />
</head>
<body>
<div id="bg">
<div id="logo">
<img src="images/logo_and_name.png" alt="" width="305" height="78" />
</div>
<div id="main">
<div id="out"><h3><p align="right"><a href="index3.php">Home</a>&nbsp;&nbsp;|<a href="logout.php">logout</a></p></h3></div>
<!-- header begins -->
<div id="header">	
	
	<div id="slider-wrapper">        
					             <div id="slider" class="nivoSlider">
									<img src="images/header.jpg" alt="" title="" />
									<img src="images/header2.jpg" alt="" title="" />
									<img src="images/header3.jpg" alt="" title="" />
									<img src="images/header4.jpg" alt="" title="" />								
                                   	
		</div>        
      </div>
								
<script type="text/javascript" src="lib/jquery-1.4.3.min.js"></script>
    <script type="text/javascript" src="lib/jquery.nivo.slider.pack.js"></script>
    <script type="text/javascript">
    $(window).load(function() {
        $('#slider').nivoSlider();
    });
    </script>
	
    <script language="JavaScript">
function validate(){
if ((document.form2.userid.value=="") || (document.form2.lastname.value=="") ||(document.form2.firstname.value=="") ||(document.form2.password.value=="") ||(document.form2.emailadress.value==""))
{
window.alert("Please Enter Important Informations!");
return false;
}
 else
 {
 return true;
 }
}


</script>

</div>
        <div id="buttons">
		<ul>
			<li class="first"><a href="home.php"  title="">Home</a></li>
            <li><a href="UserList.php" title="">User List</a></li>
			<li><a href="listofbusinessApp.php" title="">Business Permit</a></li>
			<li><a href="real_property.php" title="">Real Property</a></li>
			
			<li><a href="#" title="">Contact</a></li>
		</ul></div>
<!-- header ends -->
<!-- content begins -->
<div id="content_bg">
  <a href="UserList.php" title="back to User List"><img src="images/back (2).png" width="38" height="38"></a>
<center>
        <font size="5"><strong><h3>EDIT USER</h3></strong></font>
     
        
        <?php 
		$x=$_GET['userid']; 
		$db_name = "business-is";
	$table_name = "user";

	$user = "root";
	$pass = "";
	
	$connection = mysql_connect("localhost","$user","$pass")
	or die(mysql_error());

	$db = mysql_select_db($db_name, $connection) or die(mysql_error());

	$sql = "SELECT * FROM $table_name where userid = '$x' ";

	$result = mysql_query($sql, $connection) or die(mysql_error());

	$num= mysql_num_rows($result);
    $m=0;
	$v;
		
	if($num<1)
	{
		$display_block = "<p><em>Empty...</em> </p>";
	}
	else
	{
	$number=0;
	while ($row = mysql_fetch_array($result))

	{   
	 
		$number++;
	    $userid = $row['userid'];
	    $uname = $row['uname'];
		$lastname = $row['lastname'];
		$firstname = $row['firstname'];
		$password = $row['password'];
		$emailadress = $row['emailadress'];
		
	
	 
	}
	}
		
		?>
      
        <table background="images/scroll3.jpg" width="428" border="0">
        <form name="form2" method="post" action="">
        <tr><td>
        <input type="hidden" name="userid" id="userid" value="<?php echo $x; ?>">
        </td>
        <td>
        <font color="#00CCCC"><strong>Current Information</strong></font></td>
        <td>
        <font color="#00CCCC"><strong>Enter New Information</strong></font></td>
        </tr>
          <tr>
            <td width="78"><font color="#00CCCC">User ID:</font></td>
            <td width="141">
              <font color="#00CCCC" size="3"><strong><?php echo $uname; ?></strong></font></td>
            <td width="195">
              <label>
                <input type="text" name="uname" id="textfield" value="">
                </label></td>
          </tr>
          <tr>
            <td><font color="#00CCCC">Last Name:</font></td>
            <td><font color="#00CCCC" size="3"><strong><?php echo $lastname; ?></strong></font></td>
            <td><input type="text" name="lastname" id="textfield2"></td>
          </tr>
          <tr>
            <td><font color="#00CCCC">First Name:</font></td>
            <td><font color="#00CCCC" size="3"><strong><?php echo $firstname; ?></strong></font></td>
            <td><input type="text" name="firstname" id="textfield3"></td>
          </tr>
          <tr>
            <td><font color="#00CCCC">Password</font></td>
            <td><font color="#00CCCC" size="3"><strong><?php echo $password; ?></strong></font></td>
            <td><input type="password" name="password" id="textfield4"></td>
          </tr>
          <tr>
            
         
          <tr>
            <td><font color="#00CCCC">Email Address:</font> </td>
            <td><font color="#00CCCC" size="3"><strong><?php echo $emailadress; ?></strong></font></td>
            <td><input type="text" name="emailadress" id="textfield5"></td>
          </tr>
                   <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td><label>
              <input type="submit" name="btn_submit2" id="button" value="Submit" onClick="return validate()">
            </label></td>
          </tr>
          </form>  
        </table>
    
        <?php
		
		if(isset($_POST['btn_submit2']))
		   {


	$db_name = "business-is";
	$table_name = "user";
	$user = "root";
	$pass = "";

	
	$connection = mysql_connect("localhost","$user","$pass")
	or die(mysql_error());

	$db = mysql_select_db($db_name, $connection) or die(mysql_error());
	
	$sql = "UPDATE $table_name SET uname = '$_POST[uname]',lastname = '$_POST[lastname]', firstname = '$_POST[firstname]', password = '$_POST[password]', emailadress = '$_POST[emailadress]' WHERE userid = '$_POST[userid]'";

	$result = mysql_query($sql, $connection) or die(mysql_error());
	echo "USER SUCCESSFULLY UPDATED!";
}
?>
	

          
        </center>
         
    </div>

</div>
<!-- content ends -->
<!-- footer begins -->
<div id="footer">
   <a href="http://validator.w3.org/check?uri=referer">Copyrights © 2012</a> | <a href="http://guinobatan.gov.ph/index.php/guinobatan/index">Municipality of Guinobatan</a>. | All rights reserved. 
      </p></div>
<!-- footer ends -->
</div>
</div>
</body>
</html>